package nii.game.mobileserio.enemy;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

import android.content.Context;

public class Plant {
	
	// DECLAREATIONS ====================================
	private BitmapTextureAtlas plant_BitmapTextureAtlas;
	private TiledTextureRegion plant_TiledTextureRegion;
	private AnimatedSprite plant_AnimatedSprite;

	private float positionX = 0;
	private float positionY = 0;
	
	// CONTRUCTOR =======================================
	public Plant(){
		
	}
	
	//========================================|| onLoadResources ||===========================================//
	
	public void onLoadResources(Engine mEngine, Context mContext) {
		
		BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
		this.plant_BitmapTextureAtlas = new BitmapTextureAtlas(256, 64, TextureOptions.DEFAULT);
		this.plant_TiledTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.plant_BitmapTextureAtlas, mContext,
						"plant_1.png", 0, 0, 4, 1);
		mEngine.getTextureManager().loadTexture(this.plant_BitmapTextureAtlas);

	}

	//==========================================|| onLoadScene ||============================================//
	
	public void onLoadScene(Scene mScene) {

		plant_AnimatedSprite = new AnimatedSprite(this.positionX, this.positionY, this.plant_TiledTextureRegion.deepCopy());
		plant_AnimatedSprite.animate(200);
		plant_AnimatedSprite.setCullingEnabled(true);
		mScene.attachChild(plant_AnimatedSprite);
	}
	
	// setPosition ===============================
	public void setPosition(float pX, float pY){
		positionX = pX;
		positionY = pY;
	}
	
	// AnimatedSprite getAnimatedSprite ==========
	public AnimatedSprite getAnimatedSprite(){
		return plant_AnimatedSprite;
	}
}
